import React, { createContext, useState, useContext } from 'react'
const Context = createContext(null)
const ParentComp = ({children}) => {
  const [userinfo, setUserinfo] = useState({
    age: '231',
    name: 'glack'
  })
  return <div>
    ParentComp
    <Context.Provider value={userinfo}>
      {children}
    </Context.Provider>
  </div>
}
const ChildComp1 = () => {
  const {age, name} = useContext(Context)
  return <div>
    ChildComp1
    my name is {name}, i 'm {age} years old
  </div>
}
const ChildComp2 = () => {
  return <div>
    ChildComp2
  </div>
}
const ContextHooks = () => {
  return (<>
    <ParentComp>
      <ChildComp1 />
      <ChildComp2 />
    </ParentComp>
  </>)
}
export default ContextHooks